#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	int n;scanf("%d",&n);
	std::vector<long long> v(n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%lld",&v[i]);
	}
	sort(v.begin(),v.end());
	long long ans=0;
	for (int i = 0; i < n; ++i)
	{
		ans+=(v[i]*i-v[i]*(n-i-1));
	}
	printf("%lld\n", ans);
	return 0;
}